package com.viu.technology.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.Map;

@RestController
@RequestMapping("/pay")
public class PayController {

    @PostMapping("/notify")
    public void notify(HttpServletRequest request, HttpServletResponse response) throws IOException {
        InputStream inputStream = null;
        StringBuffer sb = new StringBuffer();
        inputStream = request.getInputStream();
        String s;
        BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
        while ((s = in.readLine()) != null) {
            sb.append(s);
        }
        in.close();
        inputStream.close();

        //Map<String,String> map=

        System.out.println(sb);

        PrintWriter writer = response.getWriter();
        writer.write("1");
        writer.flush();
        writer.close();

    }
}
